using System;
using System.Collections.Generic;

using System.IO;
using System.Text.Json;
using System.Windows;

namespace Tryit.LOLApi.Models
{
    public class RegionCoordinates
    {
        public Point Ionia { get; set; } = new Point(960, 300);
        public Point Zaun { get; set; } = new Point(960, 330);
        public Point Noxus { get; set; } = new Point(960, 360);
        public Point BandleCity { get; set; } = new Point(960, 390);
        public Point Piltover { get; set; } = new Point(960, 420);
        public Point WarCollege { get; set; } = new Point(960, 450);
        public Point MountTargon { get; set; } = new Point(960, 480);
        public Point LeiSe { get; set; } = new Point(960, 510);
        public Point Judgment { get; set; } = new Point(960, 540);
        public Point BlackRose { get; set; } = new Point(960, 570);
        public Point ShadowIsles { get; set; } = new Point(960, 600);
        public Point IronSun { get; set; } = new Point(960, 630);
        public Point CrystalScar { get; set; } = new Point(960, 660);
        public Point Equilibrium { get; set; } = new Point(960, 690);
        public Point ShadowStream { get; set; } = new Point(960, 720);
        public Point WatchSea { get; set; } = new Point(960, 750);
        public Point ConquerSea { get; set; } = new Point(960, 780);
        public Point Kalamanda { get; set; } = new Point(960, 810);
        public Point PiltoverPolice { get; set; } = new Point(960, 840);
        public Point Bilgewater { get; set; } = new Point(960, 870);
        public Point Demacia { get; set; } = new Point(960, 900);
        public Point Freljord { get; set; } = new Point(960, 930);
        public Point FearlessPioneer { get; set; } = new Point(960, 960);
        public Point Shurima { get; set; } = new Point(960, 990);
        public Point TwistedTreeline { get; set; } = new Point(960, 1020);
        public Point DragonNest { get; set; } = new Point(960, 1050);
        public Point BaronRealm { get; set; } = new Point(960, 1080);
        public Point CanyonPeak { get; set; } = new Point(960, 1110);
        public Point EduNet { get; set; } = new Point(960, 1140);

        public static RegionCoordinates LoadFromFile(string filePath)
        {
            try
            {
                if (File.Exists(filePath))
                {
                    string json = File.ReadAllText(filePath);
                    return JsonSerializer.Deserialize<RegionCoordinates>(json) ?? new RegionCoordinates();
                }
            }
            catch (Exception)
            {
                // 如果加载失败，返回默认值
            }
            return new RegionCoordinates();
        }

        public void SaveToFile(string filePath)
        {
            try
            {
                string json = JsonSerializer.Serialize(this);
                File.WriteAllText(filePath, json);
            }
            catch (Exception)
            {
                // 保存失败时的处理
            }
        }
    }
}